import { defineStore } from "pinia"
import axios from 'axios';
import { marked, renderer } from '@/utils/handleMarked/defaultHandle';

const useMdStore = defineStore('md', {
    state: () => {
        return {
            mdContent: "", //左侧md内容  默认
            previewContent: "",//右侧preview内容  默认
        }
    },
    actions: {
        async getInitContent(payload: any) {
            console.log(payload, 'payload')
            axios.get('/public/echarts疑难杂症.md').then((res) => {
                this.mdContent = res.data;
                const markdownText = res.data;
                this.previewContent = marked(markdownText, { renderer: renderer });
            });
        }
    },
    getters: {
        defaultMdContent: state => state.mdContent,
        defaultMdPreviewContent: state => state.previewContent
    }
})

export { useMdStore }